package com.itheima.charstream;

import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.Charset;

/*
字符输入流
直接指定字符集
 */
public class Demo06 {

    public static void main(String[] args) throws IOException {
        FileReader reader = new FileReader("day13\\b.txt", Charset.forName("gbk"));
        char[] chars = new char[1024];//1024个字//提前准备好的容器


    /*    int len = reader.read(chars);//len  读取到字的个数
        System.out.println("读取到了" + len + "个字");
        System.out.println(chars);//打印字符数组 直接打印内容   */
      /*  int  len;
        while ((len=reader.read(chars))!=-1){

            //chars  0,len
            String s = new String(chars, 0, len);
            System.out.println(s);

        }*/
      while (true){

          int len = reader.read(chars);
          System.out.println("这一次读了"+len+"个字");
          System.out.println("这些字是:"+chars);
      }
        //reader.close();


    }
}
